#ifndef BUTTON_H
#define BUTTON_H

#include "element.h"

class QLUISHARED_EXPORT Button : public Element
{
    Q_OBJECT
public:
    Button();

    /**
     * @brief type
     * @return
     *
     * Fix error "RTTI symbol for class 'Button' has bad type"
     * I don't know why.
     */
    virtual QString type() const override;

    /*********************************************************************
     *                    Copying
     * *******************************************************************/
public:
    virtual bool copyFrom(const Element *e) override;
    virtual Element* clone() const override;


    /*********************************************************************
     *                    Content
     * *******************************************************************/
public:
    Q_PROPERTY(QString text READ text WRITE setText)

    void setText(const QString& text);
    QString text() const;

private:
    QString text_;

    /*********************************************************************
     *                    Position & Size
     * *******************************************************************/
public:
    virtual QRect sizeHint() const;
    void adjustSize();


    /*********************************************************************
     *                    paint
     * *******************************************************************/
protected:
    virtual void paintEvent() override;

    /*********************************************************************
     *                    event
     * *******************************************************************/
public slots:
    void onKeyEvent(int key, int value);

protected:
    virtual bool prevUpdate() override;

signals:
    void pressed();
    void clicked();


    /*********************************************************************
     *                    MetaInfo
     * *******************************************************************/
public:
    virtual QString getSignalSignature(const QString& name) const override;
};

#endif // BUTTON_H
